package rifl.meres4.development.step.impl;

import org.osgi.service.log.LogService;

import rifl.meres4.commons.model.Software;
import rifl.meres4.commons.model.UIComponent;
import rifl.meres4.commons.step.AbstractWorkflowStep;
import rifl.meres4.commons.step.IWorkflowStep;
import rifl.meres4.development.step.IIntegrationStep;
import rifl.meres4.development.step.IUIImplementationStep;

/**
 * Adds 5 new UI Implementation Class to the software components.
 * 
 * @author Mark Czotter
 * @author Miklos Szennai
 * 
 */
public class UIImplementationStep extends AbstractWorkflowStep implements
		IUIImplementationStep {

	@Override
	public Software doStep(Software software) {
		for (int i = 0; i < 5; i++) {
			software.addComponent(new UIComponent("UIImplClass_" + i));	
		}
		return software;
	}
	
	@Override
	public void put(Software software) throws InterruptedException {
		if (log != null) {
			log.log(LogService.LOG_INFO, "Putting messages into nextSteps!");
		}
		for (IWorkflowStep step : nextSteps) {
			if (step instanceof IIntegrationStep) {
				((IIntegrationStep) step).addToUIInputQueue(software);
			}
		}
	}

}
